package cn.iscorpio;

public class Synchonized重入 {

    private static int count = 0;

    public static synchronized void method() {
        if (count <= 20) {
            count++;
            System.out.println(Thread.currentThread().getName() + ", count=" + count);
        }
        mmethod();

    }

    public static void mmethod() {
        synchronized (Synchonized重入.class) {
            if (count <= 120) {
                count++;
                System.out.println(Thread.currentThread().getName() + ", count=" + count);
            }
            method();
        }
    }

    public static void main(String[] args) {
        new Thread(() -> {
            Synchonized重入.method();
        }).start();

        new Thread(() -> {
            Synchonized重入.mmethod();
        }).start();
    }


}
